<?php
function get_events($offset, $limit)
{
	global $bdd;
	$offset =(int) $offset;
	$limit = (int) $limit;
	
	$reponse = $bdd->prepare('SELECT nom, id, description, dateDeb, dateAjout , photo, chemin FROM event ORDER BY dateAjout DESC LIMIT :offset, :limit');
	$reponse->bindParam(':offset',$offset, PDO::PARAM_INT);
	$reponse->bindParam(':limit', $limit, PDO::PARAM_INT);
	$reponse->execute();
	
	$events = $reponse->fetchAll();
	
	return $events;
}

function slide_events($offset, $limit)
{
	global $bdd;
	$offset =(int) $offset;
	$limit = (int) $limit;

	$reponse = $bdd->prepare('SELECT DISTINCT nom, description, dateDeb, id, dateAjout , chemin, photo FROM event ORDER BY dateDeb DESC LIMIT :offset, :limit');
	$reponse->bindParam(':offset',$offset, PDO::PARAM_INT);
	$reponse->bindParam(':limit', $limit, PDO::PARAM_INT);
	$reponse->execute();

	$slides = $reponse->fetchAll();

	return $slides;
}

function get_users($offset, $limit)
{
	global $bdd;
	$offset =(int) $offset;
	$limit = (int) $limit;

	$reponse = $bdd->prepare('SELECT pseudo, pays, nbEvent FROM user ORDER BY nbEvent DESC LIMIT :offset, :limit');
	$reponse->bindParam(':offset',$offset, PDO::PARAM_INT);
	$reponse->bindParam(':limit', $limit, PDO::PARAM_INT);
	$reponse->execute();

	$users = $reponse->fetchAll();

	return $users;
}

?>